﻿using System;
using System.Web.Mvc;

using MSAcademic.v2.Web.Areas.Admin.Models.Home;

namespace MSAcademic.v2.Web.Areas.Admin.Controllers
{
    public partial class HomeController : Controller
    {
        public ActionResult Index()
        {
            var model = _indexModelFactory();

            if (!model.CanView) { return RedirectToRoute("Index"); }

            return View(model);
        }
    }

    public partial class HomeController
    {
        private readonly Func<IndexModel> _indexModelFactory;

        public HomeController(
            Func<IndexModel> indexModelFactory)
        {
            _indexModelFactory = indexModelFactory;
        }
    }
}
